<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/include/common/gridbackhead.jsp"%>
<%!
private class PageAction extends BaseAction{
	ResultSet rs = null;
	
	//准备action的环境变量 每次请次都会执行此方法 可在此方法中初如化一些变量
	protected void prepareActionEnv() throws Exception{
		
	}
	
	//加載頁面默認數據
	protected boolean onLoadDefault() throws Exception{
		onSearchRetrieveResult();
		return true ;
	}
	
	// 取出查询結果
	protected void onSearchRetrieveResult() throws Exception{
		String sql = onSearchGetSql();
		if(sql == null){ret.setErrorInfo("查询语句异常,请联系资讯部!");return;}
		rs = utils.executeQuery("info5",sql);
		ret.SetSearchResult(rs);
	}

	//取出查詢語句
	protected String onSearchGetSql() throws Exception{
		StringBuilderEx sql =  new StringBuilderEx("select b.wfname ,count(a.sn) as cnt from wf..wf004 a, wf..wf003 b left join"
		+" (select a.sn ,count(b.sn) as cnt from pan..PAN_SUBPRO_APPIP a, pan..PAN_SUBPRO_APPHRNUM b"
		+" where a.sn = b.applySn and b.status = 1"
		+" group by a.sn) c on  b.wfdatakeyvalue = c.sn"
		+" where a.wf003sn = b.sn and a.wf003version = b.version"
		+" and b.wf001sn = 12 and (a.isfinsh = 0  or c.cnt > 0)");
		sql.Append(" and a.ophrnum = '%1$s'",utils.getHrNum());
		if(!form.isNullOrEmpty("whr")){
			sql.Append(form.gpsv("whr"));
		}
		sql.Append(" group by  b.wfname ");
		return sql.toString();
	}

}
%>
<%@include file="/include/common/gridbackend.jsp"%>
